package com.coco.controller;

import com.coco.model.CollectionStatus;
import com.coco.model.VideoModel;
import com.coco.service.VideoService;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletRequest;
import java.util.List;

/**
 * @author GHOSTLaycoo
 * @date 2020/4/21 - 17:31
 */

@RestController
@RequestMapping("video")
public class VideoController {

    @Autowired
    private VideoService videoService;

    @ApiOperation(value = "视频点赞并收藏转变")
    @PostMapping("/changCollectionStatus")
    public ResponseEntity<Integer> changCollectionStatus(@RequestBody CollectionStatus collectionStatus, HttpServletRequest request){
        return ResponseEntity.ok(videoService.changCollectionStatus(collectionStatus,request));
    }

    @ApiOperation(value = "视频是否被收藏")
    @GetMapping("/isCollection/{id}")
    public ResponseEntity<Integer> isCollection(@PathVariable("id") String videoId, HttpServletRequest request){
        return ResponseEntity.ok(videoService.isCollection(videoId,request));
    }

    @ApiOperation(value = "通过用户搜索获取收藏信息")
    @GetMapping("/selectCollectionByUserId")
    public ResponseEntity<List<VideoModel>> selectCollectionByUserId(HttpServletRequest request){
        return ResponseEntity.ok(videoService.selectCollectionByUserId(request));
    }


}
